#!/bin/sh
TORHOME=/var/run/tor
if [ ! -d "$TORHOME" ] ; then
  mkdir -p "$TORHOME"
  busybox addgroup -S tor && busybox adduser -h "$TORHOME" -S -G tor tor
  chown -R tor:tor "$TORHOME"
  su -s /bin/sh - tor -c "cd ~ ; mkdir -p env ; echo $TORHOME > env/HOME"
fi
[ "$1" = "--prereqs" ] && exit 0
exec chpst -e $TORHOME/env -u tor tor 2>&1
